import type { Statistics } from '@/types'

// 模拟统计数据
const mockStatistics: Statistics = {
  totalFiles: 126,
  totalSize: 1024 * 1024 * 1024 * 15.6, // 15.6GB
  totalViews: 45680,
  totalDuration: 125400, // 秒
  categoryStats: [
    { name: '教育', count: 42, size: 1024 * 1024 * 1024 * 6.2 },
    { name: '音乐', count: 28, size: 1024 * 1024 * 1024 * 3.8 },
    { name: '娱乐', count: 23, size: 1024 * 1024 * 1024 * 2.9 },
    { name: '新闻', count: 18, size: 1024 * 1024 * 1024 * 1.8 },
    { name: '电影', count: 15, size: 1024 * 1024 * 1024 * 0.9 }
  ],
  uploadTrend: [
    { date: '2024-01-08', count: 5 },
    { date: '2024-01-09', count: 8 },
    { date: '2024-01-10', count: 12 },
    { date: '2024-01-11', count: 6 },
    { date: '2024-01-12', count: 15 },
    { date: '2024-01-13', count: 9 },
    { date: '2024-01-14', count: 11 }
  ]
}

// 模拟API延迟
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))

export const statisticsApi = {
  // 获取统计数据
  async getStatistics(): Promise<Statistics> {
    await delay(400)
    return { ...mockStatistics }
  },

  // 获取实时统计
  async getRealTimeStats(): Promise<{
    onlineUsers: number
    todayUploads: number
    todayViews: number
    systemLoad: number
  }> {
    await delay(200)
    return {
      onlineUsers: Math.floor(Math.random() * 100) + 50,
      todayUploads: Math.floor(Math.random() * 20) + 5,
      todayViews: Math.floor(Math.random() * 1000) + 500,
      systemLoad: Math.random() * 100
    }
  }
} 